package org.projsquirrel;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.HashMap;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.Scroller;
import android.widget.TextView;

public class FullComment extends Activity {
	String FILENAME = "data_file";
	private HashMap commentmap;
	private TextView txtcomment;
	
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
		commentmap = new HashMap();
		commentmap.put("Love/Hate","I love my squirrels. I look forward to them everyday. I have a little corn feeder in the yard that has two little chairs so that they could bring a friend for lunch. My squirrels know me. They especially like peanut butter cookies for special treats. We have gray, copper and we use to have black squirrels. I have the whole neighborhood feeding them.");
		commentmap.put("Profound","I feed squirrels with great regularity. My Polish family lived in what is now Ukraine under Stalin. He, as you know, created the great famine that killed in excess of 20 million people. In order to make the famine even more deadly he had the animals, even dogs and cats taken away to make the effect of the famine even worse...I spend about $50 to $100 a month on food for the squirrels. I do this because my mother told me that we need to thank them for their giving of their lives for so many, many people who had nothing and we thank them by feeding them.");
		commentmap.put("Interactions with Other Animals","Our cat goes out on a leash and harness and I think the squirrels know just how long his leash is. They like to hang from the tree and taunt the cat. He sits at the patio door and watches the birds and squirrels." +
	"We have a dog who seems to now pretty much ignore them and they do the same to him. They can be within two feet of each other and the dog does not attempt to chase and the squirrel does not chatter." +
	"We have a cat and when the squirrels are in the trees and getting ready to eat their corn on the feeder...[and] see the cat they start barking at it and the cat just lays there wagging his tail." +
	"[The squirrel] likes to peek over the top of the fence and watch our little dog in the yard. There was one a long time ago who would sit on top of our old redwood stockade fence, peel off pieces of the wood and throw it at the dog we had then. I wouldn\'t have believed it if I hadn\'t seen it myself!");
		commentmap.put("Scientific Nuggets","Our street is 8 large blocks long. We had black squirrels only in the first two blocks, then fox squirrels only in the next two blocks and the gray squirrels occupying the next four blocks. Now, the black squirrels occupy the first four blocks with very few red squirrels around. And, the gray squirrels still own the last four blocks. It is a uniquely segregated neighborhood." +
	"My high school biology class did a census in 1991-1993 to illustrate different sampling techniques. I no longer have the data, but it did show mostly fox squirrels at that time. The niche is now filled almost exclusively by grays. The fox is almost a rarety in Palatine." +
	"We had only fox squirrels until approx. 6 years ago, now the greys outnumber the fox 3:1.");
		commentmap.put("Black Squirrels","A BLACK squirrel was in our driveway. It was all black, except that its tail had a lot of long very rusty-red hairs in it. I\'ve just never seen a black squirrel in the Chicago area before." +
	"This has been the second time in the last two weeks that we have observed a black squirrel in our front yard. We always put nuts out for the squirrels and he has begun to make himself at home. He is BLACK with one or two small light patches of white/grey." +
	"I saw a beautiful black squirrel in Lincoln Park, four blocks from where I live. This squirrel was not a variety of the gray squirrel. He was shiny black with long silky fur and a thick tail and was almost as large as a fox squirrel.");
		commentmap.put("Around the Country and the World","I live in Southwestern Ontario and we have black and grey squirrels, about a ratio of 10 black to 1 grey squirrels. I thought that the only place they existed was in Ontario, but I am interested to know where else they live." +
	"Eastern grays have pushed out the California grays in our urban and suburban Sacramento areas. The park around the State capitol in downtown Sacramento is teeming with brown fox squirrels." +
	"The squirrels on the campus of Hope College in Holland, Michigan, are coal black in color, and plentiful.");
        setContentView(R.layout.fullcomment); 
        Bundle bundle = getIntent().getExtras();
        String title = bundle.getString("title");
        txtcomment = (TextView)findViewById(R.id.txtComment);
        this.setTitle(title);
        if(commentmap.get(title)!=null)
        	txtcomment.setText((CharSequence)commentmap.get(title));
        else
        {
        	FileInputStream fin=null;
        	BufferedReader in=null;
        	 try {
        	        fin = openFileInput(FILENAME);
        	    	in = new BufferedReader(new InputStreamReader(fin));
        	    	String str;
        	    	while((str=in.readLine())!=null) {
        	    		String[] tokens = str.split(",");
        	    		if(title.equals(tokens[0])) {
        	    			txtcomment.setText(tokens[1]);
        	    		}
        	    	}
        	        //fin.close();
        	        //in.close();
        	        }
        	        catch(Exception e) {
        	        	e.printStackTrace();
        	        }
        }
        //txtcomment.setScroller(new Scroller(this));
	}

}
